<template>
    <view class="content">
        <text class="content-text">{{textTips}}</text>
        <!-- 加载条 -->
        <w-loading
            :text="_i18n('common').loading"
            mask="true"
            click="false"
            ref="loading"
        ></w-loading>
    </view>
</template>

<script>
const MyApp = getApp();
const globalData = MyApp.globalData;
export default {
    computed: {
        i18n() {
            return globalData.$t('index');
        },
        _i18n: {
            set() {
                return globalData.$t;
            },
            get() {
                return globalData.$t;
            }
        }
    },
    data() {
        return {
    		textTips: '初始化中~嘿咻ヾﾉ≧∀≦)o...',
        };
    },
    onLoad() {
        let _this = this;
        MyApp.addEventListenerClipboard(_this, e => {
            if (e == 2) {
                _this.init();
            }
        });
    },
    methods: {
        init() {
            let config = uni.getStorageSync('sys_config'), _this = this;
            if (config.hasOwnProperty('show_ad')) {
                config.show_ad = isNaN(parseInt(config.show_ad)) ? 0 : config.show_ad;
                _this.gotoPage(config);
            } else {
                _this.textTips ='啊咧(@_@;)~网络好像出问题了，重新进入小程序试试？';
            }
        },
        gotoPage(config) {
            // 是否显示开屏广告
            if (config.show_ad == 1) {
                // 广告页
                uni.reLaunch({
                    url: '/pages/guide/list'
                });
            } else {
                MyApp.goHome();
            }
        }
    }
};
</script>

<style>
.content {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    align-content: center;
    height: 100vh;
}
.content-text {
    font-size: 12px;
}
</style>
